//
//  ZWUserModel.swift
//  ZWWeibo
//
//  Created by flyiron on 16/4/19.
//  Copyright © 2016年 flyiron. All rights reserved.
//

import UIKit

class ZWUserModel: NSObject,NSCoding {
    var uid: String?

    var expires_in: NSTimeInterval = 0 {
        didSet{
            expiresDate = NSDate(timeIntervalSinceNow: expires_in)
        }
    }
    var expiresDate: NSDate?
    var access_token: String?
    
    var remind_in: String?
    
    var name: String?
    
    var avatar_large: String?
    
    init(dict: [String: AnyObject]) {
        super.init()
        setValuesForKeysWithDictionary(dict)
    }
    
    required init?(coder aDecoder: NSCoder) {
        uid = aDecoder.decodeObjectForKey("uid") as? String
        expires_in = aDecoder.decodeDoubleForKey("expires_in")
        access_token = aDecoder.decodeObjectForKey("access_token") as? String
        remind_in = aDecoder.decodeObjectForKey("remind_in") as? String
        name = aDecoder.decodeObjectForKey("name") as? String
        avatar_large = aDecoder.decodeObjectForKey("avatar_large") as? String
        expiresDate = aDecoder.decodeObjectForKey("expiresDate") as? NSDate
        
    }
    
    func encodeWithCoder(aCoder: NSCoder) {
        aCoder.encodeObject(uid, forKey: "uid")
        aCoder.encodeDouble(expires_in, forKey: "expires_in")
        aCoder.encodeObject(access_token, forKey: "access_token")
        aCoder.encodeObject(remind_in, forKey: "remind_in")
        aCoder.encodeObject(name, forKey: "name")
        aCoder.encodeObject(avatar_large, forKey: "avatar_large")
        aCoder.encodeObject(expiresDate, forKey: "expiresDate")
    }
    
}
